﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BAL;
using Objects;
using System.Collections.Generic;

public partial class Admin_UCControls_UCChuDe : System.Web.UI.UserControl
{
    public static string srtPath;

    public static ChuDe ItemChuDe = new ChuDe();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
          LoadChuDe();
        }
    }

    public string PathImage()
    {
        return srtPath = "images/Generic Card/ChuDe";
    }

    public static List<ChuDe> ListChuDe;

    public void LoadChuDe()
    {

        ListChuDe = new List<ChuDe>();
        ListChuDe = BALChuDe.GetAllItem();

        dtlChuDe.DataSource = ListChuDe;
        dtlChuDe.DataBind();

    }

    protected void btnThem_Click(object sender, EventArgs e)
    {
        Response.Redirect("../Admin/ChuDe_Update.aspx");
    }

    protected void dtlChuDe_ItemCommand(object source, DataListCommandEventArgs e)
    {
        int item;

        if (e.CommandName == "Xoa")
        {
            foreach (ChuDe itemChuDe in ListChuDe)
            {
                if (itemChuDe.Id == Convert.ToInt16(e.CommandArgument.ToString()))
                {
                    item = BALChuDe.Update_ChuDe(Convert.ToInt16(e.CommandArgument.ToString()), itemChuDe.TenChuDe,ItemChuDe.DuongDan.ToString(),ItemChuDe.GhiChu.ToString(),-1, itemChuDe.SapXep);

                }
            }

        }
    }
}
